//
//  SellerInfoHeaderView.m
//  欢乐美食
//
//  Created by Mac on 15/7/19.
//  Copyright (c) 2015年 遇水. All rights reserved.
//

#import "SellerInfoHeaderView.h"
#import "UIImageView+WebCache.h"
#import "ImageAndTextDealController.h"
#import <AlipaySDK/AlipaySDK.h>
#import "Order.h"
#import "MSDeals.h"

#import "Config.h"

#import "MSDeals.h"


@interface SellerInfoHeaderView()

@property (weak, nonatomic) IBOutlet UIImageView *dealImage;   //图片
@property (weak, nonatomic) IBOutlet UILabel *pice;     //价格
@property (weak, nonatomic) IBOutlet UILabel *oldPice;   //老的价格
@property (weak, nonatomic) IBOutlet UILabel *businessName;    //店铺名称
@property (weak, nonatomic) IBOutlet UILabel *dealDeci;    //描述

- (IBAction)buy;
- (IBAction)imageWithText;

@end

@implementation SellerInfoHeaderView


-(void)setDeal:(MSDeals *)deal
{
    _deal = deal;
    //设置控件的内容
    self.pice.text = [self NSNumberFormNSString:deal.current_price];
    NSString *str =[[self NSNumberFormNSString:deal.list_price]stringByAppendingString:@"元"];
    
    self.oldPice.text = str ;
    [self.dealImage setImageWithURL:deal.image_url placeholderImage:nil];
    self.businessName.text = deal.title;
   
    self.dealDeci.text = deal.details;
    
    float height = self.dealDeci.frame.size.height;
    
    CGRect frame = self.frame;
    frame.size.height += height;
    self.frame = frame;

}

//将number类型转化为nsstring
-(NSString *)NSNumberFormNSString:(NSNumber *)number
{
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
    NSString *str = [formatter stringFromNumber:number];
    return str;
}



- (IBAction)buy {
    //此处使用支付宝的支付
    Order *order = [[Order alloc]init];
    //    order.partner = ;
    //    order.seller = ;
    //    order.tradeNO = ;       //订单号
    order.productName = self.deal.title;
    order.productDescription = self.deal.desc;
    order.amount = [NSString stringWithFormat:@"%@",self.deal.current_price];
    
    order.notifyURL = @"";      //回调地址
    order.service = @"mobile.securitypay.pay";
    order.paymentType = @"1";
    order.inputCharset = @"utf-8";
    order.itBPay = @"30m";
    
    NSString *appScheme = @"";
    
    
    //将商品拼接成字符串
    NSString *orderSpec = [order description];
    //    id<>
    
}
- (IBAction)imageWithText {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:ImageAndTextNotification object:self];
    
    
}

@end
